package com.ruihu.admin.module.business.task.domain.entity;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruihu.admin.common.domain.BaseEntity;
import com.ruihu.admin.constant.CommonConst;
import com.ruihu.admin.module.business.task.domain.dto.ElectricCoreDataAddDTO;
import com.ruihu.admin.module.business.task.domain.dto.ElectricCoreDataDTO;
import com.ruihu.admin.module.business.task.domain.dto.ElectricCoreDataUpdateDTO;
import com.ruihu.admin.util.RequestTokenUtil;
import lombok.Data;

import java.util.Date;
import java.util.Objects;

/**
 * [ 电芯拆解数据 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c)  瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date 2022-10-21 13:38:51
 * @since JDK1.8
 */

@Data
@TableName("t_electric_core_data")
public class ElectricCoreDataEntity extends BaseEntity {


    /**
     * 子任务ID
     */
    private Long subTaskId;

    /**
     * 电芯电压
     */
    private String voltage;

    /**
     * 电芯重量
     */
    private String weight;

    /**
     * 极组合芯厚度
     */
    private String cellThickness;

    /**
     * 极组厚度
     */
    private String groupThickness;

    /**
     * 正极柱下侧1
     */
    private String positivePoleBottom1;

    /**
     * 防爆阀下侧1
     */
    private String explosionTrapBottom1;

    /**
     * 负极柱下侧1
     */
    private String negativePoleBottom1;

    /**
     * 正极柱下侧2
     */
    private String positivePoleBottom2;

    /**
     * 防爆阀下侧2
     */
    private String explosionTrapBottom2;

    /**
     * 负极柱下侧2
     */
    private String negativePoleBottom2;


    /**
     * 创建人
     */
    private Long createBy;


    /**
     * 更新人
     */
    private Long updateBy;

    /**
     * 版本号
     */
    private Integer revision;



    public static ElectricCoreDataEntity convertToElectricCoreDataEntity(ElectricCoreDataAddDTO addDTO) {
        if (addDTO == null) {
            return null;
        }

        ElectricCoreDataEntity entity = new ElectricCoreDataEntity();
        entity.setSubTaskId(addDTO.getSubTaskId());
        entity.setVoltage(addDTO.getVoltage());
        entity.setWeight(addDTO.getWeight());
        entity.setCellThickness(addDTO.getCellThickness());
        entity.setGroupThickness(addDTO.getGroupThickness());
        entity.setPositivePoleBottom1(addDTO.getPositivePoleBottom1());
        entity.setExplosionTrapBottom1(addDTO.getExplosionTrapBottom1());
        entity.setNegativePoleBottom1(addDTO.getNegativePoleBottom1());
        entity.setPositivePoleBottom2(addDTO.getPositivePoleBottom2());
        entity.setExplosionTrapBottom2(addDTO.getExplosionTrapBottom2());
        entity.setNegativePoleBottom2(addDTO.getNegativePoleBottom2());
        entity.setRevision(CommonConst.DEFAULT_OPTI_LOCK_REVISION);
        return entity;
    }


    public static ElectricCoreDataEntity convertToElectricCoreDataEntity(ElectricCoreDataUpdateDTO updateDTO) {
        if (updateDTO == null) {
           return null;
        }

        ElectricCoreDataEntity entity = new ElectricCoreDataEntity();
        entity.setId(updateDTO.getId());
        entity.setSubTaskId(updateDTO.getSubTaskId());
        entity.setVoltage(updateDTO.getVoltage());
        entity.setWeight(updateDTO.getWeight());
        entity.setCellThickness(updateDTO.getCellThickness());
        entity.setGroupThickness(updateDTO.getGroupThickness());
        entity.setPositivePoleBottom1(updateDTO.getPositivePoleBottom1());
        entity.setExplosionTrapBottom1(updateDTO.getExplosionTrapBottom1());
        entity.setNegativePoleBottom1(updateDTO.getNegativePoleBottom1());
        entity.setPositivePoleBottom2(updateDTO.getPositivePoleBottom2());
        entity.setExplosionTrapBottom2(updateDTO.getExplosionTrapBottom2());
        entity.setNegativePoleBottom2(updateDTO.getNegativePoleBottom2());
        return entity;
    }

    public static ElectricCoreDataEntity convertToElectricCoreDataEntity(ElectricCoreDataDTO dto) {
        if (dto == null) {
           return null;
        }

        ElectricCoreDataEntity entity = new ElectricCoreDataEntity();
        entity.setId(dto.getId());
        entity.setSubTaskId(dto.getSubTaskId());
        entity.setVoltage(dto.getVoltage());
        entity.setWeight(dto.getWeight());
        entity.setCellThickness(dto.getCellThickness());
        entity.setGroupThickness(dto.getGroupThickness());
        entity.setPositivePoleBottom1(dto.getPositivePoleBottom1());
        entity.setExplosionTrapBottom1(dto.getExplosionTrapBottom1());
        entity.setNegativePoleBottom1(dto.getNegativePoleBottom1());
        entity.setPositivePoleBottom2(dto.getPositivePoleBottom2());
        entity.setExplosionTrapBottom2(dto.getExplosionTrapBottom2());
        entity.setNegativePoleBottom2(dto.getNegativePoleBottom2());
        entity.setCreateTime(dto.getCreateTime());
        entity.setCreateBy(dto.getCreateBy());
        entity.setUpdateTime(dto.getUpdateTime());
        entity.setUpdateBy(dto.getUpdateBy());
        return entity;
    }

    public static ElectricCoreDataEntity copyIgnoreNullAndEmpty(ElectricCoreDataEntity sourceEntity, ElectricCoreDataEntity destEntity) {
        if (Objects.isNull(sourceEntity))
            return destEntity;
        if (Objects.nonNull(sourceEntity.getId())) {
           destEntity.setId(sourceEntity.getId());
        }
        if (Objects.nonNull(sourceEntity.getSubTaskId())) {
           destEntity.setSubTaskId(sourceEntity.getSubTaskId());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getVoltage())) {
           destEntity.setVoltage(sourceEntity.getVoltage());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getWeight())) {
           destEntity.setWeight(sourceEntity.getWeight());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getCellThickness())) {
           destEntity.setCellThickness(sourceEntity.getCellThickness());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getGroupThickness())) {
           destEntity.setGroupThickness(sourceEntity.getGroupThickness());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getPositivePoleBottom1())) {
            destEntity.setPositivePoleBottom1(sourceEntity.getPositivePoleBottom1());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getExplosionTrapBottom1())) {
            destEntity.setExplosionTrapBottom1(sourceEntity.getExplosionTrapBottom1());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getNegativePoleBottom1())) {
            destEntity.setNegativePoleBottom1(sourceEntity.getNegativePoleBottom1());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getPositivePoleBottom2())) {
            destEntity.setPositivePoleBottom2(sourceEntity.getPositivePoleBottom2());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getExplosionTrapBottom2())) {
            destEntity.setExplosionTrapBottom2(sourceEntity.getExplosionTrapBottom2());
        }
        if (StrUtil.isNotEmpty(sourceEntity.getNegativePoleBottom2())) {
            destEntity.setNegativePoleBottom2(sourceEntity.getNegativePoleBottom2());
        }
        if (Objects.nonNull(sourceEntity.getCreateTime())) {
            destEntity.setCreateTime(sourceEntity.getCreateTime());
        }
        if (Objects.nonNull(sourceEntity.getCreateBy())) {
            destEntity.setCreateBy(sourceEntity.getCreateBy());
        }
        if (Objects.nonNull(sourceEntity.getUpdateTime())) {
            destEntity.setUpdateTime(sourceEntity.getUpdateTime());
        }
        if (Objects.nonNull(sourceEntity.getUpdateBy())) {
            destEntity.setUpdateBy(sourceEntity.getUpdateBy());
        }
        if (Objects.nonNull(sourceEntity.getRevision())) {
            destEntity.setRevision(sourceEntity.getRevision());
        }
        return destEntity;
    }
}
